import request from '@/config/axios'

// 部门 VO
export interface DepartmentVO {
  id: number // 编号
  departName: string // 部门名称
  description: string // 学校介绍
  schoolId: number // 学校编号
}
export interface DepartmentForSelectVo{
  id: number // 编号
  departName: string // 部门名称
}

// 部门 API
export const DepartmentApi = {
  // 查询部门分页
  getDepartmentPage: async (params: any) => {
    return await request.get({ url: `/td/department/page`, params })
  },

  // 查询部门详情
  getDepartment: async (id: number) => {
    return await request.get({ url: `/td/department/get?id=` + id })
  },

  // 新增部门
  createDepartment: async (data: DepartmentVO) => {
    return await request.post({ url: `/td/department/create`, data })
  },

  // 修改部门
  updateDepartment: async (data: DepartmentVO) => {
    return await request.put({ url: `/td/department/update`, data })
  },

  // 删除部门
  deleteDepartment: async (id: number) => {
    return await request.delete({ url: `/td/department/delete?id=` + id })
  },

  // 导出部门 Excel
  exportDepartment: async (params) => {
    return await request.download({ url: `/td/department/export-excel`, params })
  },
  //根据学校编号获取部门信息
  getDepartmentsBySchoolId: async (schoolId)=>{
    return await request.get({ url: `/td/department/getDepartmentsBySchoolId?schoolId=` + schoolId })
  }
}
